home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / GIFLIB12.ARJ / GIF_ERR.C < prev    next >
C/C++ Source or Header  |  1990-09-06  |  4KB  |  131 lines

  1. /*****************************************************************************
  2. *   "Gif-Lib" - Yet another gif library.                     *
  3. *                                         *
  4. * Written by:  Gershon Elber            IBM PC Ver 0.1,    Jun. 1989    *
  5. ******************************************************************************
  6. * Handle error reporting for the GIF library.                     *
  7. ******************************************************************************
  8. * History:                                     *
  9. * 17 Jun 89 - Version 1.0 by Gershon Elber.                     *
  10. *****************************************************************************/
  11.  
  12. #include <stdio.h>
  13. #include "gif_lib.h"
  14.  
  15. #define PROGRAM_NAME    "GIF_LIBRARY"
  16.  
  17. int _GifError = 0;
  18.  
  19. #ifdef SYSV
  20. static char *VersionStr =
  21.         "Gif library module,\t\tGershon Elber\n\
  22.     (C) Copyright 1989 Gershon Elber, Non commercial use only.\n";
  23. #else
  24. static char *VersionStr =
  25.     PROGRAM_NAME
  26.     "    IBMPC "
  27.     GIF_LIB_VERSION
  28.     "    Gershon Elber,    "
  29.     __DATE__ ",   " __TIME__ "\n"
  30.     "(C) Copyright 1989 Gershon Elber, Non commercial use only.\n";
  31. #endif /* SYSV */
  32.  
  33. /*****************************************************************************
  34. * Return the last GIF error (0 if none) and reset the error.             *
  35. *****************************************************************************/
  36. int GifLastError(void)
  37. {
  38.     int i = _GifError;
  39.  
  40.     _GifError = 0;
  41.  
  42.     return i;
  43. }
  44.  
  45. /*****************************************************************************
  46. * Print the last GIF error to stderr.                         *
  47. *****************************************************************************/
  48. void PrintGifError(void)
  49. {
  50.     char *Err;
  51.  
  52.     switch(_GifError) {
  53.     case E_GIF_ERR_OPEN_FAILED:
  54.         Err = "Failed to open given file";
  55.         break;
  56.     case E_GIF_ERR_WRITE_FAILED:
  57.         Err = "Failed to Write to given file";
  58.         break;
  59.     case E_GIF_ERR_HAS_SCRN_DSCR:
  60.         Err = "Screen Descriptor already been set";
  61.         break;
  62.     case E_GIF_ERR_HAS_IMAG_DSCR:
  63.         Err = "Image Descriptor is still active";
  64.         break;
  65.     case E_GIF_ERR_NO_COLOR_MAP:
  66.         Err = "Neither Global Nor Local color map";
  67.         break;
  68.     case E_GIF_ERR_DATA_TOO_BIG:
  69.         Err = "#Pixels bigger than Width * Height";
  70.         break;
  71.     case E_GIF_ERR_NOT_ENOUGH_MEM:
  72.         Err = "Fail to allocate required memory";
  73.         break;
  74.     case E_GIF_ERR_DISK_IS_FULL:
  75.         Err = "Write failed (disk full?)";
  76.         break;
  77.     case E_GIF_ERR_CLOSE_FAILED:
  78.         Err = "Failed to close given file";
  79.         break;
  80.     case E_GIF_ERR_NOT_WRITEABLE:
  81.         Err = "Given file was not opened for write";
  82.         break;
  83.     case D_GIF_ERR_OPEN_FAILED:
  84.         Err = "Failed to open given file";
  85.         break;
  86.     case D_GIF_ERR_READ_FAILED:
  87.         Err = "Failed to Read from given file";
  88.         break;
  89.     case D_GIF_ERR_NOT_GIF_FILE:
  90.         Err = "Given file is NOT GIF file";
  91.         break;
  92.     case D_GIF_ERR_NO_SCRN_DSCR:
  93.         Err = "No Screen Descriptor detected";
  94.         break;
  95.     case D_GIF_ERR_NO_IMAG_DSCR:
  96.         Err = "No Image Descriptor detected";
  97.         break;
  98.     case D_GIF_ERR_NO_COLOR_MAP:
  99.         Err = "Neither Global Nor Local color map";
  100.         break;
  101.     case D_GIF_ERR_WRONG_RECORD:
  102.         Err = "Wrong record type detected";
  103.         break;
  104.     case D_GIF_ERR_DATA_TOO_BIG:
  105.         Err = "#Pixels bigger than Width * Height";
  106.         break;
  107.     case D_GIF_ERR_NOT_ENOUGH_MEM:
  108.         Err = "Fail to allocate required memory";
  109.         break;
  110.     case D_GIF_ERR_CLOSE_FAILED:
  111.         Err = "Failed to close given file";
  112.         break;
  113.     case D_GIF_ERR_NOT_READABLE:
  114.         Err = "Given file was not opened for read";
  115.         break;
  116.     case D_GIF_ERR_IMAGE_DEFECT:
  117.         Err = "Image is defective, decoding aborted";
  118.         break;
  119.     case D_GIF_ERR_EOF_TOO_SOON:
  120.         Err = "Image EOF detected, before image complete";
  121.         break;
  122.     default:
  123.         Err = NULL;
  124.         break;
  125.     }
  126.     if (Err != NULL)
  127.     fprintf(stderr, "\nGIF-LIB error: %s.\n", Err);
  128.     else
  129.     fprintf(stderr, "\nGIF-LIB undefined error %d.\n", _GifError);
  130. }
  131.